package com.wjh.service.impl;


import com.wjh.pojo.LoginUser;
import com.wjh.utils.SecurityUtils;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ps")
public class PermissionService {

    /**
     * 判断是否具有对应权限
     * @param permission
     * @return
     */
    public boolean hasPermission(String permission){
        LoginUser loginUser = SecurityUtils.getLoginUser();
        //判断是否是管理员
        if(SecurityUtils.isAdmin()){
            return true;
        }
        //取出用户的权限
        List<String> perms = loginUser.getPerms();
        return perms.contains(permission);
    }
}
